from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
from api_test.testcases.user_action.login_test import TestCaseLogin


class TestRefreshToken(HttpRunner):

    config = Config("刷新token").base_url("http://39.107.78.120:8083/okcloud").verify(False)

    teststeps = [
         Step(
            RunTestCase("登录")
            .with_variables(**{"phone": "18222878910", "password": "aaaaaa"})
            .call(TestCaseLogin)
            .export(*["token"])
        ),

        Step(
            RunRequest("刷新token")
            .post("/token/refreshToken")
            .with_params(**{"OKCLOUD-TOKEN": "$token", "token": "$token", "type": "1"})
            .validate()
            .assert_equal("body.code", 200)
        )
    ]